package com.gxuwz.attend.service.admin;
import com.gxuwz.attend.dao.admin.DepartmentDao;
import com.gxuwz.attend.entity.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DepartmentService {
    @Autowired
    private DepartmentDao departmentDao;


    // 获取所有二级学院
    public List<Department> getAllDepartments(String id, String name, int size, int offset) {
        // 如果 ID 和名称都为空，返回所有部门
        if ((id == null || id.isEmpty()) && (name == null || name.isEmpty())) {
            return departmentDao.getAllDepartments(size, offset); // 调用DAO获取所有部门
        } else  {
            return departmentDao.findDepartments(id,name,size, offset);
        }
    }

    // 添加二级学院
    public void addDepartment(Department department) {
        departmentDao.addDepartment(department); // 调用DAO添加部门
    }

    // 删除二级学院
    public void deleteDepartment(String depID) {
        departmentDao.deleteDepartment(depID); // 调用DAO删除部门
    }




    // 更新二级学院信息
    public void updateDepartment(Department department) {
        departmentDao.updateDepartment(department); // 调用DAO更新部门
    }
}
